package com.sbj.dto.res;

import cn.zhxu.bs.bean.DbField;
import cn.zhxu.bs.bean.SearchBean;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.sbj.dto.jackson.CustomDecimalSerialize;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * @author summer
 * @version 1.0
 * @date 2024/8/10 16:19
 */
@Data
@SearchBean(tables = " member_store s left join buy_goods b ON b.id=s.buy_id" +
        " left join member se ON s.seller_id=se.id " +
        " left join member bu ON bu.id=s.buyer_id" ,autoMapTo = "s" ,orderBy = "s.order_time DESC")
public class MemberStoreRes implements Serializable {

    @DbField("s.id")
    private Integer id;

    @DbField("s.transfer")
    private Integer transfer;

    @DbField("s.buy_id")
    private Integer buyId;

    @DbField("b.goods_name")
    private String goodsName;

    @DbField("s.orderNo")
    private String orderNo;

    @DbField("b.goods_image")
    private String goodsImage;

    /**
     * 卖方
     */
    @DbField("s.seller_id")
    private Integer sellerId;

    @DbField("se.nickName")
    private String sellerName;

    @DbField("se.phone")
    private String sellerPhone;

    /**
     * 买方
     */
    @DbField("s.buyer_id")
    private Integer buyerId;

    @DbField("bu.nickName")
    private String buyerName;

    @DbField("bu.phone")
    private String buyerPhone;

    @DbField("b.goods_price")
    @JsonSerialize(using = CustomDecimalSerialize.class)
    private BigDecimal goodsPrice;

    @DbField("s.order_state")
    private Integer orderState;

    @DbField("CASE WHEN s.order_state=0 THEN '交易中' WHEN s.order_state=1 THEN '已完成' WHEN s.order_state=2 THEN '已取消' ELSE '寄卖中' END ")
    private String stateName;

    /**
     * 0 买家仓库  1 卖家仓库
     */
    @DbField("s.type")
    private Integer type;

    @DbField("s.order_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private LocalDateTime orderTime;

    @DbField("s.grad_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private LocalDateTime gradTime;

    @DbField("s.complete_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private LocalDateTime completeTime;

}
